package stack;

public class MyArrayStack<E> implements MyStack<E> {
    private int size;
    private Object[] arr = new Object[10];

    public MyArrayStack(int size) {
        arr = new Object[size];
    }

    public MyArrayStack() {
    }

    @Override
    public void push(E o) {
        arr[size] = o;
        size++;
    }

    @Override
    public E pop() {
        Object o = arr[size - 1];
        size--;
        return (E) o;
    }

    @Override
    public E peek() {
        return (E) arr[size - 1];
    }

    @Override
    public boolean isEmpty() {
        return size == 0 ? true : false;
    }

    public boolean isFull() {
        return size == arr.length ? true : false;
    }
}
